﻿using System.Drawing;

namespace TestAnimation
{
    class Particle
    {
        int life;
        public Vector position;
        readonly Vector velocity;
        Color color;
        public Pen pen;

        public Particle(Vector pos, Vector vel, int lif)
        {
            position = pos;
            velocity = vel;
            life = lif;
            if (life == 0) life = Globals.particleMaxLife;
        }

        public bool Move()
        {
            position += velocity;
            return (--life > 0);       
        }

        public void Draw(Screen screen)
        {
            //var p=new Point();
            

            if (life < Globals.particleMaxLife / 3) color =  Color.Gray;
            else if (life < Globals.particleMaxLife * 2 / 3) color = Color.Red;
            else color = Color.Yellow;

            pen = new Pen(color);

            screen.Add(this);
            //p.X = (int)(position.X * (double)scrWidth / Globals.maxX);
            //p.Y = (int)(position.Y * (double)scrHeight / Globals.maxY);
            //g.DrawLine(pen, p.X, p.Y, p.X+1, p.Y);
        }
    }
}
